/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package mini_game_fx;

import javafx.event.ActionEvent;
import javafx.event.Event;
import javafx.event.EventHandler;
import javafx.scene.canvas.Canvas;
//import mini_game_fx.;

/**
 *
 * @author Joshua
 */
public class MiniGameLoopEventHandler implements EventHandler<ActionEvent>{
    MiniGameFx game;
    
    public MiniGameLoopEventHandler(MiniGameFx game){
        this.game = game;
    }

    @Override
    public void handle(ActionEvent event) {
        try{
//            game.beginGame();
            game.update();//ateGUI();
    //        ((MiniGameCanvas)game.getCanvas()).paintComponent(game);
            ((MiniGameGroup)game.getStage().getScene().getRoot()).paintComponent();
//            ((MiniGameGroup)game.getStage().getScene().getRoot()).getChildren().get(1).
            
            
//            game.get
//            game.endUsingData();
        }catch(IllegalMonitorStateException e){
            e.printStackTrace();
        }
//        finally{
//            game.endUsingData();
//        }
    }
}
